package com.liucxu.qiushimeinv.Utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.liucxu.qiushimeinv.App.App;

/**
 * Preference操作工具类
 * Created by liukanshan on 2017/1/1.
 */

public class PreferenceUtils {

    public static String GetUserName(){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        return preferences.getString("user_name_key","");
    }


    public static String GetUserPassword(){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        return preferences.getString("password_key","");
    }

    public static String GetUserToken(){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        return preferences.getString("token_key","");
    }

    public static void SaveUserName(String user_name){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=preferences.edit();
        editor.putString("user_name_key",user_name);
        editor.commit();
    }

    public static void SaveUserPassword(String password){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=preferences.edit();
        editor.putString("password_key",password);
        editor.commit();}

    public static void SaveUserToken(String token){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=preferences.edit();
        editor.putString("token_key",token);
        editor.commit();
    }

    public static void ClearUserInfo(){
        SharedPreferences preferences=App.GetInstance().getSharedPreferences("user_info", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=preferences.edit();
        editor.remove("user_name_key");
        editor.remove("password_key");
        editor.remove("token_key");
        editor.commit();
    }
}
